package com.ruoyi.ruoyiqywechat.service.impl;

import com.ruoyi.ruoyiqywechat.service.ChatAiService;
import com.ruoyi.ruoyiqywechat.service.qywechat.QyMessageService;
import com.ruoyi.system.api.RemoteChanceService;
import com.ruoyi.system.api.RemoteChatAiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class ChatAiServiceImpl implements ChatAiService {

    @Autowired
    private RemoteChatAiService remoteChatAiService;

    @Autowired
    private QyMessageService qyMessageService;
    @Override
    public void sendText(String content,String userId) {
        String call = remoteChatAiService.call(content,userId);
        System.out.println("远程AI返回："+call);
        if(call == null)return;;
        HashMap<String,Object> data = new HashMap<>();
        data.put("conversation_id","S:"+userId);
        data.put("content",call);
        //发送给对应的用户
       String rep =  qyMessageService.send_private(data);
        System.out.println("发送私聊消息的响应结果："+rep);
    }
}
